package com.jltx.xq.coroutinesandrxpro

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.View
import com.jltx.xq.coroutinesandrxpro.coroutines.CoroutinesLearn2
import com.jltx.xq.coroutinesandrxpro.rxjava.RxJava2Learn2

class MainActivity2 : AppCompatActivity(), View.OnClickListener {
    private val handler = Handler(Looper.getMainLooper())

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main2)
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.rx_learn2_1 ->
                RxJava2Learn2.intervalCancel(handler)
            R.id.rx_learn2_2 ->
                RxJava2Learn2.customIntervalCancel(handler)
            R.id.cor_learn2_1 ->
                CoroutinesLearn2.intervalCancel(handler)
            R.id.cor_learn2_2 ->
                CoroutinesLearn2.multipleJobCancel(handler)
            R.id.cor_learn2_3 ->
                CoroutinesLearn2.customIntervalWithCancel(handler)
            R.id.cor_learn2_4 ->
                CoroutinesLearn2.customIntervalWithCancel2(handler)
            R.id.cor_learn2_5 ->
                CoroutinesLearn2.customIntervalWithCancel3(handler)

        }
    }
}